﻿@using Vit.Web.Modules;
@model IEnumerable<Vit.Web.Modules.IModule>
@{
    Layout = "~/Views/Shared/_Html.cshtml";
    ViewBag.Title = "Administration Index Page";
    
}
<h2>Modules</h2>
<table id="widgetList">
    <thead>
        <tr>
            <th>Module</th>
            <th>Title</th>
            <th>Current Version</th>
            <th>Installed Version</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
    @foreach (var pw in this.Model)
    {
        var installedModule = ((IQueryable<ModuleInfo>)ViewBag.InstalledModules).FirstOrDefault(o => o.Name == pw.Name);
        <tr>
            <td>@pw.Name</td>
            <td>@pw.Title</td>
            <td>@pw.Version</td>
            <td>@(installedModule == null ? "" : installedModule.Version.ToString())</td>
            <td>
                @if (installedModule == null)
                {
                    <a href="/Module/Install/@pw.Name">Install</a>
                }
                else
                {
                    if (installedModule != null && string.Compare(installedModule.Version, pw.Version.ToString(), true) < 0)
                    {
                    <a href="/Module/Update/@pw.Name">Update</a>
                    }
                    <a href="/Module/UnInstall/@pw.Name">UnInstall</a>
                }
            </td>
        </tr>
    }
    </tbody>
</table>
